my %word;
open W,">a.txt" or die $!;
select W;
while(<>){
	chomp;
	s/(A|B)/$1\n/g;
	print; 
}
close;
select STDOUT;
open FILE,"<a.txt" or die $!;
while(<FILE>){
	chomp;
	$word{$1}++ if /(A|B)/;
}
foreach(sort keys %word){
	print "$_=>$word{$_}";
	print "\n";
}
close FILE;
